package com.ruoyi.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.BusSpjgFee;
import com.ruoyi.business.service.IBusSpjgFeeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 能源消耗Controller
 * 
 * @author ruoyi
 * @date 2023-07-21
 */
@Api(tags = "食品加工-收费情况")
@RestController
@RequestMapping("/spjg/fee")
public class BusSpjgFeeController extends BaseController
{
    @Autowired
    private IBusSpjgFeeService busSpjgFeeService;

    /**
     * 查询能源消耗列表
     */
    @ApiOperation("列表")
    @GetMapping("/list")
    public TableDataInfo list(BusSpjgFee busSpjgFee)
    {
        startPage();
        List<BusSpjgFee> list = busSpjgFeeService.selectBusSpjgFeeList(busSpjgFee);
        return getDataTable(list);
    }

    /**
     * 导出能源消耗列表
     */
    @PreAuthorize("@ss.hasPermi('fee:fee:export')")
    @Log(title = "能源消耗", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusSpjgFee busSpjgFee)
    {
        List<BusSpjgFee> list = busSpjgFeeService.selectBusSpjgFeeList(busSpjgFee);
        ExcelUtil<BusSpjgFee> util = new ExcelUtil<BusSpjgFee>(BusSpjgFee.class);
        util.exportExcel(response, list, "能源消耗数据");
    }

    /**
     * 获取能源消耗详细信息
     */
    @PreAuthorize("@ss.hasPermi('fee:fee:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(busSpjgFeeService.selectBusSpjgFeeById(id));
    }

    /**
     * 新增能源消耗
     */
    @PreAuthorize("@ss.hasPermi('fee:fee:add')")
    @Log(title = "能源消耗", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusSpjgFee busSpjgFee)
    {
        return toAjax(busSpjgFeeService.insertBusSpjgFee(busSpjgFee));
    }

    /**
     * 修改能源消耗
     */
    @PreAuthorize("@ss.hasPermi('fee:fee:edit')")
    @Log(title = "能源消耗", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusSpjgFee busSpjgFee)
    {
        return toAjax(busSpjgFeeService.updateBusSpjgFee(busSpjgFee));
    }

    /**
     * 删除能源消耗
     */
    @PreAuthorize("@ss.hasPermi('fee:fee:remove')")
    @Log(title = "能源消耗", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(busSpjgFeeService.deleteBusSpjgFeeByIds(ids));
    }
}
